

// import { Button } from 'element-ui'
export const addimg = (editor) => {
    const {
        Components
    } = editor;
    Components.addType('addimg', {
        model: {
            defaults: {
                tagName: 'div',
                name: 'addimg',
                attributes: {
                    class: 'loveicon'
                },
                droppable: true,
                components: [{
                    tagName: 'img',
                    attributes: {
                        id: 'click',
                        src: 'https://mybuketh.oss-cn-beijing.aliyuncs.com/loveEmpty.png'
                    },
                }],

                traits: [],
                script() {
                    var click = document.getElementById('click');
                    click.onclick = function () {
                        if (click.src.indexOf('loveEmpty.png') != -1) {
                            click.src = 'https://mybuketh.oss-cn-beijing.aliyuncs.com/trueheart.png';
                        } else {
                            click.src = 'https://mybuketh.oss-cn-beijing.aliyuncs.com/loveEmpty.png';
                        }
                    }

                },
                styles: `
                 .loveicon{
                    width: 40px;
                    height: 40px;
                }
                   
                `
            },
            init() {},
        }
    });

    // 注册组件
    editor.BlockManager.add('addimg', {
        label: '添加小图标',
        category: '其他类',
        media: '<svg t="1724152622544" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6014" width="32" height="32"><path d="M512.001023 857.386308l-3.543709-3.913123c-6.236028-1.168616-10.215666-5.347798-11.968589-9.298783-0.473791-1.065262-0.939395-2.433422-1.191128-4.03899-33.998325-27.125801-188.201359-119.909997-284.491403-176.12123C116.743888 609.785094 65.058738 504.854253 79.201853 396.72865c15.290241-116.765377 107.24556-210.577996 223.63436-228.116441 65.332984-9.846252 135.858224 16.939811 209.16481 79.631642 73.321936-62.698994 143.840012-89.514733 209.16481-79.631642 116.439966 17.553795 208.40347 111.395066 223.641523 228.212632 14.121626 108.221794-37.674041 213.174124-131.937938 267.381723-96.127338 56.116065-250.190179 148.818397-284.165991 175.921685-0.251733 1.612731-0.717338 2.980891-1.191128 4.03899-1.74576 3.949962-5.725398 8.129144-11.961426 9.305947L512.001023 857.386308zM511.99386 812.285111l1.464351 1.605567c56.730049-42.793642 259.096013-161.231101 284.217157-175.899172 83.684958-48.118927 129.615033-141.228535 117.083625-237.245356-13.500479-103.487979-94.965885-186.625468-198.10594-202.174606-59.126632-8.884344-124.56297 18.352997-194.540741 81.08883l-10.112312 9.06854-10.112312-9.06854c-69.948095-62.74402-135.391596-90.017176-194.540741-81.08883-103.096053 15.541975-184.561459 98.642624-198.098777 202.092741-12.552897 95.927793 33.279964 189.014888 116.765377 237.140978 25.201985 14.713097 227.754191 133.269259 284.528242 176.084391L511.99386 812.285111z"  p-id="6015"></path></svg>',
        content: {
            type: 'addimg'
        },
    });
};